using NL.AdreesableAsset;
using System.Collections.Generic;
using UnityEngine;
namespace NL.Advanced
{
    public class CombatSetting_Orb : MonoBehaviour
    {
        static Dictionary<AttackEffect, CombatSetting_Orb> ALL = new Dictionary<AttackEffect, CombatSetting_Orb>();
        public AttackEffect Effect;

        [Header("发球资产URL(配合后缀): Orb_Ice_Flying_XXX")]
        public string Url_Flying;
        public string Url_Dead;
        public string Url_Target;
        public string Url_Sput;

        protected string _GetUrl_Flying(string suffix = "")
        {
            return string.IsNullOrEmpty(suffix) ? Url_Flying : $"{Url_Flying}_{suffix}";
        }

        protected string _GetUrl_Target(string suffix = "")
        {
            return string.IsNullOrEmpty(suffix) ? Url_Target : $"{Url_Target}_{suffix}";
        }
        protected string _GetUrl_Dead(string suffix = "")
        {
            return string.IsNullOrEmpty(suffix) ? Url_Dead : $"{Url_Dead}_{suffix}";
        }
        //溅射
        protected string _GetUrl_Sput(string suffix = "")
        {
            return string.IsNullOrEmpty(suffix) ? Url_Dead : $"{Url_Sput}_{suffix}";
        }

        public GameObject Mod_Flying, Mod_Dead, Mod_Sput;
        // Start is called before the first frame update
        void Start()
        {
            if (!ALL.ContainsKey(Effect))
                ALL[Effect] = this;

            AA.LOAD<GameObject>(Url_Flying, (w, ob) =>
            {
                Mod_Flying = ob;
            }, gameObject);

            AA.LOAD<GameObject>(Url_Dead, (w, ob) =>
            {
                Mod_Dead = ob;
            }, gameObject);

            AA.LOAD<GameObject>(Url_Sput, (w, ob) =>
            {
                Mod_Sput = ob;
            }, gameObject);
        }

        public static GameObject GetOrb_Flying(AttackEffect effect)
        {
            var node = ALL.ContainsKey(effect) ? ALL[effect] : null;
            return node != null ? node.Mod_Flying : null;
        }
        public static GameObject GetOrb_Dead(AttackEffect effect)
        {
            var node = ALL.ContainsKey(effect) ? ALL[effect] : null;
            return node != null ? node.Mod_Dead : null;
        }

        public static GameObject GetOrb_Sput(AttackEffect effect)
        {
            var node = ALL.ContainsKey(effect) ? ALL[effect] : null;
            return node != null ? node.Mod_Sput : null;
        }

        public static string GetUrl_Flying(AttackEffect effect, string suffix = "")
        {
            var node = ALL.ContainsKey(effect) ? ALL[effect] : null;
            if (ALL.ContainsKey(effect))
                return ALL[effect]?._GetUrl_Flying(suffix);
            else
                return null;
        }
        public static string GetUrl_Target(AttackEffect effect, string suffix = "")
        {
            var node = ALL.ContainsKey(effect) ? ALL[effect] : null;
            if (ALL.ContainsKey(effect))
                return ALL[effect]?._GetUrl_Target(suffix);
            else
                return null;
        }
        public static string GetUrl_Dead(AttackEffect effect, string suffix = "")
        {
            var node = ALL.ContainsKey(effect) ? ALL[effect] : null;
            if (ALL.ContainsKey(effect))
                return ALL[effect]?._GetUrl_Dead(suffix);
            else
                return null;
        }

        public static string GetUrl_Sput(AttackEffect effect, string suffix = "")
        {
            var node = ALL.ContainsKey(effect) ? ALL[effect] : null;
            if (ALL.ContainsKey(effect))
                return ALL[effect]?._GetUrl_Sput(suffix);
            else
                return null;
        }
    }
}

